/**
 * @Project TMHSCFX
 * @Author Tran Manh Hung
 * @Email: hungtmit@gmail.com | tmh@xwebgate.com
 * @Copyright © 2011 TMH. All rights reserved
 * @Createdate Apr 13, 2011
 * @Createtime 2:30:24 PM
 */

package com.tmh.study.fAS3AMTM.chap4
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;

	public class DrawingCurves extends Sprite
	{
		private var x0:Number = 100;

		private var y0:Number = 200;

		private var x1:Number;

		private var y1:Number;

		private var x2:Number = 300;

		private var y2:Number = 200;

		public function DrawingCurves()
		{
			super();
			addEventListener(Event.ADDED_TO_STAGE, addedToStageHandler);
		}

		private function addedToStageHandler(event:Event):void
		{
			initData();
		}

		private function initData():void
		{
			stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
		}

		private function onMouseMove(event:MouseEvent):void
		{
			x1 = mouseX;
			y1 = mouseY;
			graphics.clear();
			graphics.lineStyle(1);
			graphics.moveTo(x0, y0);
			graphics.curveTo(x1, y1, x2, y2);
		}
	}
}